/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.halos.common;

import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.log4j.Logger;

/**
 *
 * @author josue
 */
public class Idioma {

    private static ResourceBundle rb;
    private final static Logger logger = Logger.getLogger(Idioma.class);
    
    
    public static String getLenguaje() {
        
            try {
                ResourceBundle.getBundle("com.halos.common.idioma." + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getLanguage()+"_Halos");
                return "com.halos.common.idioma." + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getLanguage()+"_Halos";
            } catch (Exception e) {
                logger.warn(e);
                return "com.halos.common.idioma.es_ES_Halos";
            }
        
        
    }
    
    public static String getRbValueFromKey(String objectName,String key){
        if (rb == null) {
            try {
                rb = ResourceBundle.getBundle("com.halos.common.idioma." + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getLanguage()+"_Halos");
            } catch (Exception e) {
                rb = ResourceBundle.getBundle("com.halos.common.idioma.es_ES_Halos");
            }
        }
        return rb.getString(objectName+key);
    }
    
}
